#include <bits/stdc++.h>

typedef long long ll;

using namespace std;

const int N = 1e5 + 100;
int T,n,m,L,V;
int tap[N];
struct node{
    int d,v,a;
}car[N];

void read(int &res){
    int x = 0,w = 1;
    char ch = 0;
    while(ch < '0' || ch > '9'){
        if(ch == '-') w = -1;
        ch = getchar();
    }
    while(ch >= '0' && ch <= '9'){
        x = (x<<3) + (x<<1) + (ch-'0');
        ch = getchar();
    }
    res = x * w;
}

void solve_a(){
    int cnt = 0;
    sort(tap + 1,tap + m + 1);
    for(int i = 1;i <= n;i++){
        if(car[i].d > tap[m]) continue;
        if(car[i].v > V) cnt++;
    }

    printf("%d ",cnt);
    if(!cnt) printf("%d\n",m);
    else printf("%d\n",m - 1);
}

void init(){
    memset(car,0,sizeof(car));
    memset(tap,0,sizeof(tap));
}

void solve_b(){
    int cnt = 0;
    sort(tap + 1,tap + m + 1);
    for(int i = 1;i <= n;i++){
        if(car[i].d > tap[m]) continue;
        ll s = tap[m] - car[i].d;
        double vi = 1.0 * car[i].v * car[i].v + 2 * car[i].a * s;
        if(vi > 1.0 * V * V) cnt++;
    }
    printf("%d %d\n",cnt,m - 1);
}

void force(){

}

int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    read(T);
    while(T--){
        init();
        read(n);read(m);read(L);read(V);
        bool sa = true,sb = true;
        for(int i = 1;i <= n;i++){
            read(car[i].d);read(car[i].v);read(car[i].a);
            if(car[i].a != 0) sa = false;
            if(car[i].a <= 0) sb = false;
        }
        for(int i = 1;i <= m;i++) read(tap[i]);
        if(sa) solve_a();
        else if(sb) solve_b();
        else force();
    }
    return 0;
}
